//
//  HWGameYouXiView.m
//  HWanGame
//
//  Created by 陈道斌 on 2021/7/7.
//  Copyright © 2021 Chendaobin. All rights reserved.
//

#import "HWGameYouXiView.h"

@interface HWGameYouXiView()
@property(strong,nonatomic) UIView *grayView;
@property(strong,nonatomic) UIImageView *tupianiamgeView;
@property(strong,nonatomic) UIImageView *quxiaoicoIamgeView;

@end


@implementation HWGameYouXiView

- (instancetype)initWithFrame:(CGRect)frame  {
    
    if (self  = [super initWithFrame:frame]) {
        // 添加灰色背景
        [self addgrayView];
        
        [self setupUI];
        
        
    }
    return  self;
    
}


//  设置UI
- (void)setupUI {
    
    // 游戏的图片
    self.tupianiamgeView = [[UIImageView alloc] initWithFrame:CGRectMake((kScreenW-375)/2, (kScreenH-366)/2, 375, 366)];
    self.tupianiamgeView.userInteractionEnabled = YES;
 //   self.tupianiamgeView.image = [UIImage imageNamed:@"tankuanjimianico"];
    [self addSubview:self.tupianiamgeView];
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tupianiamgeViewTap)];
    [self.tupianiamgeView addGestureRecognizer:tap1];
    
    // 取消
    self.quxiaoicoIamgeView = [[UIImageView alloc] initWithFrame:CGRectMake((kScreenW-26-13), (kScreenH-366)/2-34, 26, 69)];
    self.quxiaoicoIamgeView.userInteractionEnabled = YES;
    self.quxiaoicoIamgeView.image = [UIImage imageNamed:@"quxiaoico"];
    [self addSubview:self.quxiaoicoIamgeView];
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(quxiaoicoIamgeViewTap)];
    [self.quxiaoicoIamgeView addGestureRecognizer:tap2];
    
    
    
    
    
 
    
}

// 进去详情界面
- (void)tupianiamgeViewTap  {
    
    NSString *gidstr = [NSString stringWithFormat:@"%@",self.dataDic[@"gid"]];
    
    HWGameDetailController *game = [[HWGameDetailController alloc]init];
    game.gameId = gidstr;
    [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:game animated:YES];
    
    [self removeFromSuperview];
    
}

//取消按钮
- (void)quxiaoicoIamgeViewTap {
    
    [self removeFromSuperview];
    
    
}

-(void)setDataDic:(NSDictionary *)dataDic {
    
    _dataDic = dataDic;
    
    NSString *urlstr = [NSString stringWithFormat:@"%@",dataDic[@"image"]];
    
    [self.tupianiamgeView sd_setImageWithURL:[NSURL URLWithString:urlstr] placeholderImage:nil];
    
    
    
    
    
    
    
    
}






// 添加灰色View
-(void)addgrayView {
    
    self.grayView = [[UIView alloc]init];
    self.grayView.frame  = CGRectMake(0,0, kScreenW, kScreenH);
    
    self.grayView.backgroundColor =  RGB(0, 0, 0);
    self.grayView.alpha = 0.7;
    [self addSubview:self.grayView];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapView:)];
    //  tap.delegate = self;
    [self.grayView addGestureRecognizer:tap];
    
    
    
    
}



- (void)tapView:(UITapGestureRecognizer *)touch {
    
//     [touch.view.superview removeFromSuperview];
    //   [[NSNotificationCenter defaultCenter] postNotificationName:@"notifyName1" object:nil];
    
    
}





@end
